<?php
/*
 * author:wully_happy@163.com
 * component function test
*/
class TestComponent extends CComponent{
	
	#属性的读写操作，可以根据读写是否开放，来决定是否设置set和get方法
	#可以通过$com -> atr来调用
	private $atr = "";
	
	public function getAtr(){
		return $this -> atr;
	}
	
	#可以通过$com -> atr来调用
	public function setAtr($v)
	{
		$this -> atr = $v;
	}
	public static function eventMethod1($event)
	{
		echo "run enentMethod1!/n";
	}
	public function eventMethod2($event)
	{
		echo "run enentMethod2!/n";
	}
	
	public static function clickEvent($event)
	{
		echo "run clickEvent";
	}
	
	public function onTest($event)
	{
		$this->raiseEvent('onTest', $event);
	}
	
	public function onClicked($event)
	{
		$this->raiseEvent("onClicked", $event);
	}
	
	public function clickedEvent()
	{
		$callback = array($this, "clickEvent");
		$this->onClicked = $callback;
		
		$this->onClicked(new CEvent());
	}

	public function testEvent(){
		##register event
		$callback = array();
		$callback = array("TestComponent","eventMethod1");
		$this -> onTest = $callback;
		$callback = array($this,"eventMethod2");
		$this -> onTest = $callback;
		$this -> onTest(new CEvent());
	}
	public function testBehavior(){
		$name = "test2Behavior";
		$behavior = new TestBehavior();
		$this->attachBehavior($name,$behavior);
			
		
		UtilTools::dump($this);
		
//		if ($behavior->)
//			$this -> FunOfTestBehavior();
	}
}
?>